package datatype;

/**
 * Created by kevin on 15-1-4.
 */
public class Stack {
    private Item top = null;
    private class Item {
        private Object value;
        private Item next;
    }
    public Object pop(){
        if(top == null){
            return null;
        }
        Object x = top.value;
        top = top.next;
        return x;
    }
    public void push(Object x){
        Item p = new Item();
        p.value = x;
        p.next = top;
        top = p;
    }
}
